package com.fmjava.controller;

import com.fmjava.ServiceImpl.NewsServiceImpl;
import com.fmjava.domain.News;
import com.fmjava.domain.PageBean;
import com.fmjava.service.NewsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/NoticeDetailServlet")
public class NoticeDetailServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String tmp_id = request.getParameter("id");
        // 如果参数不合法，则跳转到首页
        NewsService newService=new NewsServiceImpl();
        if (tmp_id == null)
            request.getRequestDispatcher("/index.jsp").forward(request, response);

        NewsService newsService=new NewsServiceImpl();
        News notice=newsService.getOneNews(tmp_id);
        request.setAttribute("notice",notice);


        request.getRequestDispatcher("/notice_detail.jsp").forward(request, response);
        // 产品详情页初始化

    }

}
